/**
 * 解析配置类
 */
package com.sc.datacollect.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.PropertyConfigurator;

public class CommonConfig {

	public static int listenport = 0;
	/** netty端口 */
	public static int nettyfileport = 0;
	public static int nettydataport = 0;
	public static int nettyairport = 0;

	public static String mongohost = null;
	public static int mongoport = 0;
	public static String mongodbname = null;
	public static String mongouser = null;
	public static String mongopasswd = null;
	public static String mongoType = null;

	public static String orcldriverClass = null;
	public static String orcljdbcUrl = null;
	public static String orcluser = null;
	public static String orclpassword = null;

	public static String vocs = null;
	public static String heavymetal = null;
	public static String ionchromatography = null;
	public static String airfactor = null;
	public static String ocec = null;

	public static String filepath = null;

	public static int ftpport = 21;

	public static Properties siteConfig = new Properties();
	public static Properties deviceConfig = new Properties();

	static {
		try {
			FileInputStream siteconfig = new FileInputStream(Common.dir + "sitecode.properties");
			FileInputStream deviceconfig = new FileInputStream(Common.dir + "devicecode.properties");
			siteConfig.load(siteconfig);
			deviceConfig.load(deviceconfig);

			FileInputStream in = new FileInputStream(Common.dir + "base.properties");
			Properties properties = new Properties();
			properties.load(in);
			// 日志配置
			PropertyConfigurator.configure(new FileInputStream(Common.dir + "log4j.properties"));

			listenport = Integer.parseInt(properties.getProperty("listenport"));
			nettyfileport = Integer.parseInt(properties.getProperty("nettyfileport"));
			nettydataport = Integer.parseInt(properties.getProperty("nettydataport"));
			nettyairport = Integer.parseInt(properties.getProperty("nettyairport"));

			mongohost = properties.getProperty("mongohost");
			mongoport = Integer.parseInt(properties.getProperty("mongoport"));
			mongodbname = properties.getProperty("mongodbname");
			mongouser = properties.getProperty("mongouser");
			mongopasswd = properties.getProperty("mongopasswd");
			mongoType = properties.getProperty("mongoType");

			orcldriverClass = properties.getProperty("driverClass");
			orcljdbcUrl = properties.getProperty("jdbcUrl");
			orcluser = properties.getProperty("user");
			orclpassword = properties.getProperty("password");

			vocs = properties.getProperty("vocs");
			heavymetal = properties.getProperty("heavymetal");
			ionchromatography = properties.getProperty("ionchromatography");
			airfactor = properties.getProperty("airfactor");
			ocec = properties.getProperty("ocec");

			filepath = properties.getProperty("filepath");
			ftpport = Integer.parseInt(properties.getProperty("ftpport"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
